for _ in range(int(input())):
    n = int(input())
    a = int(input())
    b = int(input())
    f = 1
    for i in range(1, n + 1):
        f *= i
    p = pow(a, b)
    if f % p == 0:
        print("Yes")
    else:
        print("No")
